package com.service;

import com.dao.FindDao;
import com.entity.Dto;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by asus on 2017-02-09.
 */
public class FindService {
    private FindDao findDao = new FindDao();
    public List<Dto> laodAllFind(Dto dto,int page, int displayCount) {
        List<Dto> dtoList=null;
        try {
            dtoList = findDao.laodAllCake(dto,page,displayCount);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        for(Dto a:dtoList){
            System.out.println(a.toString());
        }
        return dtoList;
    }
    public int displayPage(Dto dto,int displayCount){
        int maxpage=0;
        int count;
        try {
            count=findDao.getCount(dto);
            maxpage=count%displayCount==0 ? count/displayCount : count/displayCount+1;
        }catch (SQLException e){
            e.printStackTrace();
        }
        return maxpage;
    }

}
